package com.xinlu.user.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import com.xinlu.common.log.Logger;
import com.xinlu.derek.common.BaseAction;
import com.xinlu.derek.common.BaseForm;
import com.xinlu.user.form.DownloadClientForm;

public class DownloadClientAction extends BaseAction {

	Logger log = Logger.getLogger(DownloadClientAction.class);
	
	private DownloadClientForm fr = new DownloadClientForm();
	
	@Override
	public String doExecute() throws Exception {
		// TODO Auto-generated method stub
		return "success";
	}

	@Override
	public void formInit() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public BaseForm getModel() {
		// TODO Auto-generated method stub
		return fr;
	}
	
//	public String downLoadFile(){
//		
//		
//		return SUCCESS;
//	}
	
	public InputStream getInputStream() throws FileNotFoundException, UnsupportedEncodingException{
		
		File file = new File("D:\\XinLuSys\\竞彩在线客户端.exe");
		
		if (file.exists()) {
			
			fr.setFilename(file.getName());
			fr.setFlleLength(file.length() + "");
			return new FileInputStream(file);
			
		}else{
			
			return null;
		}
	}

	
	
}
